import 'package:finance_app/src/utils/input_formatter_tools.dart';

import 'down_button_form.dart';
import 'form_edit_status_inherited_widget.dart';
import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class TextCurrencyPriceInputForm extends StatelessWidget {
  final String currency;
  final TextEditingController controller;
  final FocusNode focusNode;
  final VoidCallback onChangeCurrency;
  final double leftPadding;
  final double rightPadding;
  final String title;

  const TextCurrencyPriceInputForm(
      {Key key,
      this.title,
      this.currency,
      this.controller,
      this.focusNode,
      this.onChangeCurrency,
      this.leftPadding,
      this.rightPadding})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
            color: aceGrayColor,
            width: getDp(0.5),
          )),
          color: Colors.white),
      padding: EdgeInsets.only(
        left: leftPadding ?? getDp(35),
        right: rightPadding ?? getDp(35),
        top: getDp(10),
        bottom: getDp(10),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            title,
            style: TextStyle(
              color: aceBlackColor,
              fontSize: getSp(16),
              fontWeight: FontWeight.w700,
              height: 1,
            ),
          ),
          DownButtonForm(
            title: currency,
            onTap: onChangeCurrency,
          ),
          Expanded(
            child: FormStatusWidget(
              builder: (enable) => TextField(
                scrollPadding: EdgeInsets.zero,
                decoration: InputDecoration(
                    contentPadding: EdgeInsets.zero,
                    border: InputBorder.none,
                    hintText: '0.00',
                    hintStyle: TextStyle(
                      color: aceGrayColor,
                      fontSize: getSp(24),
                      fontWeight: FontWeight.w700,
                      height: 24 / 24,
                    )),
                inputFormatters: [
                  doubleLimit2InputFormatter,
                ],
                keyboardType: TextInputType.numberWithOptions(decimal: true),
                style: TextStyle(
                  color: enable ? aceBlueColor : aceBlackColor,
                  fontSize: getSp(24),
                  fontWeight: FontWeight.w700,
                  height: 24 / 24,
                ),
                enabled: enable,
                controller: controller,
                focusNode: focusNode,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
